<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        border: solid;
        padding: 10px;
      }
    </style>
  </head>
  <body>
    <div id="app"></div>

    <template id="t1">
      <div>
        <!-- <input type="text" @keydown.enter="log($event.target.value)" /> -->
        <!-- 使用键码来过滤键盘的输入 -->
        <input type="text" @keydown.65="log($event.keyCode)" />
        <hr />
        <input type="text" @keydown.keya="log($event.keyCode)" />
      </div>
    </template>
    <script src="./vue.js"></script>
    <script>
      // 使用全局配置，给键码设置别名
      Vue.config.keyCodes.keya = 65;
      const vm = new Vue({
        el: "#app",
        template: "#t1",
        methods: {
          log(ctx) {
            console.log(ctx);
          },
        },
      });
    </script>
  </body>
</html>
